define(function(require, exports, module) {

	"use strict";
	require("mui");
	require("jquery");

	var dingTalkNav = require('dd_config');
	var abpdata = require("abpinit");
	var abp = abpdata.abpstart;
	var template = require("template");
	var muiTips = require("muiTips"); //封装的弹框
	//	$(function() {
	//扫码获取货品信息跳转详情页
	mui("body").on("tap", "#scanImg", function() {
		dingTalkNav.ScanCode(ScanCode);
	});

	//扫码获取货品单号跳转详情页
	function ScanCode(data) {
		var option = {};
		var dataModel = {
			"barCode": data.text //"string"
		};
		abp.services.app.infoGoods.getModelByBarCode(dataModel, option)
			.done(function(data) {
				//$("#Customer").val(data.text);
				sessionStorage.setItem('data-stockQuery', JSON.stringify(data));
				//				sessionStorage.flags = "show";
				document.location.href = "../../src/stock/stockDetail.html?dd_nav_bgcolor=FFFF943E";
			})
			.fail(function(err) {
				$("#goodsList").html("");
				$('.mui-content').addClass("searchContentTips");
			});

	}

	var page = require("pageui");

	var dataModel = {
		"keyword": '',
		"isBom": false,
		"catalogId": 0,
		"orderBy": "",
		"whId": 0,
		"pageSize": 20,
		"pageIndex": 1
	};

	page.init({
		id: "goodsList",
		tempid: "bindGoodsList",
		isCache: true
	}, {
		swipeBack: true
	}, abp.services.app.infoGoods.getPage, dataModel).dataLoad();

	// 监听tap事件，解决 a标签 不能跳转页面问题
	mui('body').on('tap', 'a', function() {
		if(this.href) {
			document.location.href = this.href + "?dd_nav_bgcolor=FFFF943E";
		}
	});

	mui('body').on('tap', '#btnSearch', function() {

		dataModel.keyword = $("#Customer").val();
		page.dataLoad(dataModel);

	});

	mui('body').on('tap', '#goodsList li>a', function() {

		sessionStorage.setItem('data-stockQuery', JSON.stringify(page.dataCache[$(this).attr("data-id")]));

	});
	//首页客户列表返回
	var commonBack = require("commonBack");
	mui("body").on("tap", ".client-list-back", function() {
		commonBack.secondBack();
	});
	dingTalkNav.LeftNavBar(commonBack.secondBack);
	//ad
	dingTalkNav.leftAndroid(commonBack.secondBack);
	dingTalkNav.RightNavBar(false, "更多", "default");

});